<?php

class UsersController extends AppController {
	var $name = 'Users';
	
	var $components = array('Auth'); //Not necessary if declared in your app controller

	function beforeRender() {
		$this->layout="login";
		//$this->set("background", "../img/error2.JPG");
	}
	
	function beforeFilter() {
		$this->Auth->allow('register');
		//$this->Auth->loginError = "This message shows up when the wrong credentials are used";
    	//$this->Auth->authError = "This error shows up with the user tries to access a part of the website that is protected.";
	}
	

	function index() {
				
	}

	function register() {
		if (!empty($this->data)) {
			if ($this->data['User']['password'] == $this->Auth->password($this->data['User']['password_confirm'])) {
				$this->User->create();
				$this->User->save($this->data);
				$this->redirect(array('action' => 'index'));

			}
		}
	}

	function login() {
				//$this->Auth->loginRedirect = 'your url';
				$this->Auth->loginError = "No, you fool!  That's not the right password!";
	}
	
	function logout() {
		$this->Session->setFlash("You've successfully logged out");
		$this->redirect($this->Auth->logout());
	}
	
}